package com.applancer.adapter;

import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.applancer.model.GeneralModel;
import com.applancer.model.MenuModel;
import com.applancer.nativecmsflip.R;

public class LeftMenuAdapter extends BaseAdapter{

	protected List<GeneralModel> ldata;
	
	public LeftMenuAdapter( List<GeneralModel> data )
	{
		ldata  = data;
	}
	
	@Override
	public int getCount() {
		return ldata.size();
	}

	@Override
	public Object getItem(int position) {
		return ldata.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		ViewHolder holder;
		
		if( convertView == null){
			
			LayoutInflater inflater = LayoutInflater.from(parent.getContext());
			convertView = inflater.inflate(R.layout.adapter_menu_left, null);
			
			holder = new ViewHolder();
			holder.icon = null;
			holder.title = (TextView)convertView.findViewById(R.id.leftmenuitemtitle);
			
			convertView.setTag(holder);
		}else
		{
			holder =  (ViewHolder)convertView.getTag();
		}
		
		MenuModel menuItem = (MenuModel)getItem(position);
		holder.title.setText(menuItem.getTitle());
		
		return convertView;
	}

	public int getItemViewType(int position) {
	    return 0;
	}

	public int getViewTypeCount() {
	    return 1;
	}
	
	public static class ViewHolder {
		ImageView icon;
		TextView title;
	}
	
}
